# def f(n:int)->int:
#     if (n/10)<0:
#         return n**2
#     elif (n/10)<10:
#         return (n//10)**2+(n%10)**2
#
#
# print(99//10)

def f(s: int) -> int:
    a = 0
    for i in str(s):
        a += int(i) ** 2
    return a

print(f(406))

#  2
def fun3(num):
    sum = 0
    while num>0:
        sum += (num%10)**2
        num = num // 10
    return sum
print(fun3(6))







